package com.example.rdcproject.ving.notes.entity;

import com.example.rdcproject.ving.notes.service.ClockIn;

import java.util.List;

//定义用户类
public class User {


    //实例化用户
    private static User instance=null;

   public static User getInstance(){
       if(instance==null){
           instance=new User();
       }
       return instance;
   }

    //用户的属性
    private String nickname;        //用户名
    private String password;        //密码
    private String  birthdate;         //生日
    private int wordCount;          //统计学习的单词总数
    private int continuousDays=0;     //练习打卡的天数
    private int totalStudyTime;     //学习的总时长
    private int dailyGoal;          //学习计划
    private boolean isPrivate;      //是否为私密状态
    private boolean isBlack;        //是否被拉黑
    private NewWordBook newBook;   //生词本
    private int currentWordIndex;   //单词学习进度


    public int getCurrentWordIndex() {
        return currentWordIndex;
    }

    public void setCurrentWordIndex(int currentWordIndex) {
        this.currentWordIndex = currentWordIndex;
    }

    public boolean isPrivate() {
        return isPrivate;
    }

    public void setPrivate(boolean aPrivate) {
        isPrivate = aPrivate;
    }

    public void getNewBook() {
        newBook= NewWordBook.getInstance();
    }

    public boolean isBlack() {
        return isBlack;
    }

    public void setBlack(boolean black) {
        isBlack = black;
    }

    // 添加单词到生词本中
    public void AddWord(Word word) {
        newBook.addWord(word);
    }

    // 从生词本中移除单词
    public void RemoveWord(Word word) {
        newBook.removeWord(word);
    }

    //读取生词本所有单词
    public void getAllNewWord() {
        newBook.getWordList();
    }

    public User(String nickname, String password, String birthdate, int wordCount, int continuousDays,
                int totalStudyTime, int dailyGoal, boolean isPrivate) {
        this.nickname = nickname;
        this.password = password;
        this.birthdate = birthdate;
        this.wordCount = wordCount;
        this.continuousDays = continuousDays;
        this.totalStudyTime = totalStudyTime;
        this.dailyGoal = dailyGoal;
        this.isPrivate = isPrivate;
    }

    public User() {
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(String birthdate) {
        this.birthdate = birthdate;
    }

    public void setWordCount(int wordCount) {
        this.wordCount = wordCount;
    }

    public void setContinuousDays(int continuousDays) {
        this.continuousDays = continuousDays;
    }

    public User(String nickname, String password, String birthdate, int wordCount, int continuousDays, int totalStudyTime, int dailyGoal, boolean isPrivate, boolean isBlack) {
        this.nickname = nickname;
        this.password = password;
        this.birthdate = birthdate;
        this.wordCount = wordCount;
        this.continuousDays = continuousDays;
        this.totalStudyTime = totalStudyTime;
        this.dailyGoal = dailyGoal;
        this.isPrivate = isPrivate;
        this.isBlack = isBlack;
    }

    public int getTotalStudyTime() {
        return totalStudyTime;
    }

    public void setTotalStudyTime(int totalStudyTime) {
        this.totalStudyTime = totalStudyTime;
    }

    public int getDailyGoal() {
        return dailyGoal;
    }

    //修改密码
    public void modifyPassword(String oldPassword, String newPassword) {
        if (this.password.equals(oldPassword)) {
            this.password = newPassword;
        } else {
            System.out.println("旧密码错误！");
        }
    }

    //设置学习计划
    public void setDailyGoal(int dailyGoal) {
        this.dailyGoal = dailyGoal;
    }

    //统计学习的单词总数
    public int getWordCount() {
        return wordCount;
    }

    public int getContinuousDays() {
        return continuousDays;
    }
}




